<?php
if(!isset($_GET['page'])){
    $_GET['page']=1;
}
$getpage=$_GET['page']-1;
$page=$sotin*$getpage;
$page1=$sotin*($getpage+1);
function phantrang($page, $totalpage, $link, $show)  //$link = '&page=%s'
{
    //show page
if($totalpage == 0)
{
 
} else {
    $nav_page = '<div class="navpage"> ';
    $limit_nav = 3;
    $start = ($page - $limit_nav <= 0) ? 1 : $page - $limit_nav;
    $end = $page + $limit_nav > $totalpage ? $totalpage : $page + $limit_nav;
    if($page + $limit_nav >= $totalpage && $totalpage > $limit_nav * 2){
        $start = $totalpage - $limit_nav * 2;
    }
    if($start != 1){ //show first page
        $nav_page .= '<a href="'.sprintf($link, 1).'"> [1] </a>&nbsp;&nbsp;';
    }
    if($start > 2){ //them nut ...
        $nav_page .= '<span class="current">...&nbsp;&nbsp;';
    }
     
    for($i = $start; $i <= $end; $i++){
        if($page == $i)
            $nav_page .= '<span class="current">'.$i.'&nbsp;&nbsp;';
        else
            $nav_page .= '<a href="'.sprintf($link, $i).'"> ['.$i.'] </a>&nbsp;&nbsp;';
    }
     
    if($end + 1 < $totalpage){ //them nut ...
        $nav_page .= '<span class="current">...&nbsp;&nbsp;';
    }    
    if($end != $totalpage) //show last page
        $nav_page .= '<a href="'.sprintf($link, $totalpage).'"> ['.$totalpage.'] </a>&nbsp;&nbsp;';
    $nav_page .= '</div>';
    return $nav_page;
}
}  
?>